function azq(ao){
    //$(ao).parent(".ah").hide();
    $(ao).html("抓取<img style=\"position: absolute;left:0em;z-index:2\" src='/collect/loading.gif'>");
    o.url.value=$(ao).parents("tr").children(".listurl").text();
    o.gindex.value=$(ao).parents("tr").children(".gindex").text();
    o.host.value=$(ao).parents("tr").children(".pthost").text();
    $("select[name='ptid']").val($(ao).parents("tr").children(".ptid").text());
    o.tid.value=$(ao).parents("tr").children(".tid").text();
    qk();
    testt(ao);
}

function atestzq(ao){
    o.url.value= o.alisturl.value;
    o.gindex.value=o.agindex.value;
    o.host.value=o.pthost.value;
    o.ptid.value=o.aptid.value;
    o.tid.value=o.atid.value;
    qk();
    testt();
}

function aselect(ao){
    o.alisturl.value=$(ao).parents("tr").children(".listurl").text();
    o.agindex.value=$(ao).parents("tr").children(".gindex").text();
    $("select[name='aptid']").val($(ao).parents("tr").children(".ptid").text());
    o.pthost.value=$(ao).parents("tr").children(".pthost").text();
    o.aptid.value=$(ao).parents("tr").children(".ptid").text();
    o.aptusername.value=$(ao).parents("tr").children(".aptusername").text();
    o.atid.value=$(ao).parents("tr").children(".tid").text();
}

function uselect(ao){
    if(o.pthost.value== o.upthost.value){
        o.aptusername.value=$(ao).parents("tr").children(".uusername").text();
    }else{
        alert('该用户不是'+o.pthost.value+'的用户');
    }
}

function adel(id){
    ifr.location="reset.php?a=adel&id="+id;
}

function udel(id){
    ifr.location="reset.php?a=udel&id="+id;
}

function addautos(){
    $.post("reset.php", $(o).serializeArray(), function(data,textStatus){
        o.sB1.click();
    });
}

function adduassss(){
    $.post("reset.php?addupasss=1", $(o).serializeArray(), function(data,textStatus){
        o.sB1.click();
    });
}

function ashow(host,ptid,tid){
    if(ptid==2){
        window.open("http://"+host+"/index.php?m=content&c=index&a=lists&catid="+tid);
    }
}


function plzqs(){
//                            $.post("reset.php?plzq=1", $(o).serializeArray(), function(data,textStatus){
//                                alert("抓取完成"+data);
//                            });
    var ydata;
    var jo;
    $(".azq").each(function(){
        //this.click();
        jo=$(this);
        jo.parent(".ah").hide();
        jo.html("抓取<img style=\"position: absolute;left:0em;z-index:2\" src='/collect/loading.gif'>");


        ydata=new Array();
        ydata['s_url']=jo.parents("tr").children(".listurl").text();
        ydata['gindex']=jo.parents("tr").children(".gindex").text();
        ydata['host']=jo.parents("tr").children(".pthost").text();
        ydata['ptusername']=jo.parents("tr").children(".ptusername").text();
        ydata['ptpassword']=jo.parents("tr").children(".ptpassword").text();
        ydata['ptid']=jo.parents("tr").children(".ptid").text();
        ydata['tid']=jo.parents("tr").children(".tid").text();
        ydata['bfid']=jo.parents("tr").find("span").html();
        url="reset_send.php?onlyread=1&gather_type=6&code=&cookie=&s="+Math.random();
        $.ajax({
            type:'POST',
            async:true,
            url: url,
            s_url:ydata['s_url'],
            data:{s_url:ydata['s_url'],gindex:ydata['gindex'],host:ydata['host'],ptusername:ydata['ptusername'],ptid:ydata['ptid'],tid:ydata['tid'],ptpassword:ydata['ptpassword'],bfid:ydata['bfid']},
            dataType: "json",
            success: function(data){
                $("#B2").removeAttr("disabled");
                jo=$("#bfida"+data.bfid);
                jo.html("抓取");
                jo.parent("td").find(".ah").show();
                $("#subject").val(data.subject);
                $("#uchome-ttHtmlEditor").val(data.message);
                if($("#pbliu").attr("checked")){
                    var json=new Array();
                    var patt = new RegExp("\[img\]([^<>]+)\[\/img\]","gi");
                    var result;
                    while ((result = patt.exec(data.message)) != null)  {
                        json[json.length]['image']=result;
                        json[json.length]['subject']=data.subject;
                        json[json.length]['url']=data.url;
                    }
                    loadMore(json);
                }else {
                    data.message = data.message.replace(/\r?\n/gi, "<p>");
                    data.message = data.message.replace(/\[align=center\]/gi, "<p align=center>");
                    data.message = data.message.replace(/\[align=left\]/gi, "<p align=left>");
                    data.message = data.message.replace(/\[\/align\]/gi, "</p>");
                    data.message = data.message.replace(/\[img\](.*)\[\/img\]/gi, "<p align=center><img src=\"$1\"></p>");
                    data.message = data.message.replace(/\[img\]/gi, "<img src=\"");
                    data.message = data.message.replace(/\[\/img\]/gi, "\">");
                    data.message = data.message.replace(/\[b\]([^\[\]]*)\[\/b\]/gi, "<b>$1</b>");
                    data.message = data.message.replace(/\[b\]|\[\/b\]/gi, "");
                    $("#uchome-ifrHtmlEditor", document.body).contents().find("body").html(data.message);
                }
            }
        });
    });

}

function qk(){
    $("#subject").val("");
    $("#uchome-ttHtmlEditor").val("");
    $("#uchome-ifrHtmlEditor",document.body).contents().find("body").html("");
}

function addsle(){
    $("#addsletr").addClass("totop");
}

function zk(o){
    if($(".zk").css("display")=="none"){
        $(".zk").show();
        $(o).text("-隐藏");


    }else{
        $(".zk").hide()
        $(o).text("+展开");

    }
}
